package com.inlycat.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.inlycat.entity.Tramp;
import com.inlycat.service.TrampService;

/**
 * @author jarvan4dev@163.com
 * @since 2015年8月24日下午4:16:54
 * @category 
 **/

@Controller
@RequestMapping("/tramp")
public class TrampController {

	@Resource
	private TrampService trampService;
	
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> add(Tramp tramp){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		boolean result = trampService.insert(tramp);
		if(result){
			resultMap.put("code", 1);
			resultMap.put("message", "success");
		}else{
			resultMap.put("code", 0);
			resultMap.put("message", "fail");
		}
		
		return resultMap;
	}
	
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> delete(Tramp tramp){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		boolean result = trampService.delete(tramp);
		if(result){
			resultMap.put("code", 1);
			resultMap.put("message", "success");
		}else{
			resultMap.put("code", 0);
			resultMap.put("message", "fail");
		}
		return resultMap;
	}
	
}
